<%@page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" import="hotel.entity.*,java.util.*"%>
<%@include file="../link.html"%>
<!DOCTYPE html>
<script type="text/javascript">
$(document).ready(function() {
	$("#btn-close").click( function () { 
		var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
		parent.layer.close(index); //再执行关闭 
	});
});
</script>

<div style="padding-top:1cm">
	<form id="form" method="post" class="form-horizontal">
	
		<input type="hidden" name="roleid" value="${role.roleid}">
		<input type="hidden" name="createdTime" value="${role.createdTime}">
		<div class="form-group">
			<label  class="col-sm-3 control-label">角色名称</label>
			<div class="col-sm-6">
				<input id="roleName" name="roleName" value="${role.roleName}" class="form-control" readonly>
			</div>
		</div>

		<div class="form-group">
			<label class="col-sm-3 control-label">说明</label>
			<div class="col-sm-6">
				<textarea id="comment" name="comment" class="form-control" readonly>${role.comment}</textarea>
			</div>
		</div>

		<div class="form-group">
			<label class="col-sm-3 control-label">权限</label>
			<div class="col-sm-6">
			<%
			Map<Integer,Integer> map=new HashMap<>();
			//角色原有的权限放到map中
			List<Authority> list=((Role)request.getAttribute("role")).getAuthoritys();
			for(Authority a:list){
				map.put(a.getAuthorityid(), a.getAuthorityid());
			}
	
			list=(List<Authority>)request.getAttribute("auths");
			StringBuffer buffer=new StringBuffer();
			for(Authority a:list){
				if(map.containsKey(a.getAuthorityid())){
					buffer.append("<div class='col-sm-6'><input type='checkbox' name='auths' class='icheckbox_minimal' value='"
						+a.getAuthorityid()+"' checked=''>"+a.getAuthorityName()+"</div>");
				}else{
					buffer.append("<div class='col-sm-6'><input type='checkbox' name='auths' class='icheckbox_minimal' value='"
						+a.getAuthorityid()+"'>"+a.getAuthorityName()+"</div>");
				}
			}
			
			out.print(buffer.toString());
			%>
			</div>
		</div>

		<div class="box-footer"></div>
		
		<div class="form-group">
			<label class="col-sm-3 control-label"></label>
			<div class="col-sm-6">
				<div class="pull-right">
					<button id="btn-close" class="btn btn-close btn-primary" type="button">
						<i class="fa fa-remove"></i> 关闭
					</button>
				</div>
			</div>
		</div>
	</form>
</div>